export default {
  name: 'goods',
  data () {
    return {
      searchText: '',
      goodsList: [],
      goodsObj: {
        query: '',
        pagenum: 1,
        pagesize: 10
      },
      total: 0
    }
  },
  methods: {
    async getGoodsList () {
      const { data, meta } = await this.$get('goods', { params: this.goodsObj })
      // console.log(data)
      // console.log(meta)
      if (meta.status === 200) {
        this.goodsList = data.goods
        this.total = data.total
      }
      this.getGoodsList()
    },
    handleSizeChange (val) {
      this.goodsObj.pagesize = val
    },
    handleCurrentChange (val) {
      this.goodsObj.pagenum = val
    }
  },
  created () {
    this.getGoodsList()
  },
  watch: {
    goodsObj: {
      handler () {
        this.getGoodsList()
      },
      deep: true
    }
  }
}
